#pragma once
#include "precompiled.h"
#include "tbb/task.h"
#include "ParticlesCommon.h"

class Scenery;
class Player;
class hkpWorld;
class hkMovingRBCollectorPhantom;

namespace PhysicsManager{

	// The Physics run loop. This belongs in it's on it's own core.
	void HK_CALL run();

	 void HK_CALL Init_Havok();
	 void HK_CALL Cleanup_Havok();

	 void HK_CALL createWorld();
	 void HK_CALL cleanupWorld();

	 void HK_CALL add_RigidBody_Player( );
	 void HK_CALL add_RigidBody_Scenery( );

	 void HK_CALL add_bulletPhantom_requests(hkMovingRBCollectorPhantom* phantom, Particle *p);

	 void HK_CALL Update_UnavailableScenery( const hkReal& timeStep );
	 void HK_CALL Update(  const hkReal& timeStep );

	 void HK_CALL Update_Transforms( vector<Scenery*> &sv );
}

class PhysicsTBB: public tbb::task{
public:
	PhysicsTBB()
	{}
	tbb::task* execute(){
		PhysicsManager::run();
		return NULL;
	}
};

// Call this to start the physics loop.
void static PhysicsTBB_Run(){
	PhysicsTBB& a = *new(tbb::task::allocate_root()) PhysicsTBB();
	tbb::task::spawn( a );
	return;
}